package com.demo;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;

import java.time.Duration;

public class test2 {
    public static void main(String[] args) {
        WebDriver chromeDriver = new DriverConfig().getChromeDriver();
        chromeDriver.get("https://www.bing.com");

        chromeDriver.findElement(By.cssSelector("#sb_form_q")).sendKeys("我的世界");
        chromeDriver.findElement(By.cssSelector("#search_icon > svg")).click();

        chromeDriver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));

        WebDriverWait wait = new WebDriverWait(chromeDriver, Duration.ofSeconds(10));

        System.out.println(wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id=\"b_results\"]/li[2]"))).getText());
        chromeDriver.findElement(By.xpath("//*[@id=\"b_results\"]/li[2]/div[1]/a/div[2]/div[2]/div/cite")).click();
    }

}
